What are the ways to get a string input from user that stops accepting input when the input's length is already 30 without the need to press ENTER or any other keys. Maybe you can show some code?
My first attempt is to use:
The problem is that it still allows unlimited input and when you hit ENTER it only takes the first 30 characters.Code:char string[31]; fgets(string, 31, stdin);